package com.zufe.khw;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Test1 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        List<Integer> list = new ArrayList<>();
        while(true) {
            System.out.println("请输入一个整数：");
            String str = sc.nextLine();
            int num = Integer.parseInt(str);
            if(0 > num | num > 100){
                System.out.println("输入的数字不在0-100之间，请重新输入！");
                continue;
            }
            list.add(num);
            int sum = getSum(list);
            if (sum > 200){
                System.out.println("输入的数字之和已经超过200，程序结束！");
                break;
            }
        }
    }

    private static int getSum(List<Integer> list) {
        int sum = 0;
        for (Integer num : list) {
            sum += num;
        }
        return sum;
    }
}
